home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / LIB / ANIM_MOV.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  8.1 KB  |  219 lines

  1. package sub_arctic.lib;
  2.  
  3. import sub_arctic.anim.*;
  4. import sub_arctic.input.*;
  5.  
  6. import java.awt.Point;
  7.  
  8. /**
  9.  * A container class to move a collection of objects with under control of 
  10.  * an animation transition.  See the animation agent for details about how
  11.  * animation transitions work.
  12.  *
  13.  * @see sub_arctic.anim.animation_agent
  14.  * @see sub_arctic.anim.animatable
  15.  * @author Ian Smith
  16.  */
  17. public class anim_mover_container 
  18. extends shrink_wrap_container implements animatable {
  19.  
  20.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  21.  
  22.   /**
  23.    * Call this to setup a transition for this object. Note: you may call
  24.    * this more than once... if you do so, it is possible that you could
  25.    * have multiple active transitions. This is useful! However, be
  26.    * aware that previous calls are not cancelled by this call.
  27.    *
  28.    * @param transition t the transition we schedule for this object.
  29.    */
  30.   public void set_transition(transition t) {
  31.     /* tell the agent what we want */
  32.     manager.animation.schedule_transition(t);
  33.   }
  34.  
  35.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  36.  
  37.   /**
  38.    * Construct a new sprite container. Initially, there is no transition
  39.    * scheduled.
  40.    *
  41.    * @param int        xpos  initial x position of the container.
  42.    * @param int        ypos  initial y position of the container.
  43.    * @param interactor child child object to install under this container.
  44.    */
  45.   public anim_mover_container(int xpos, int ypos, interactor child) 
  46. {
  47.     super(xpos,ypos,0,false);
  48.     setup_for_fixed_children(1);
  49.     set_child(0,child);
  50.     child.set_x(0);
  51.     child.set_y(0);
  52.     _cback_obj=null;
  53.   }
  54.  
  55.    //had:
  56.    //* @exception general PROPAGATED.
  57.  
  58.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  59.  
  60.   /**
  61.    * Construct a new sprite container with a callback. Initially, there is no 
  62.    * transition scheduled.<p>
  63.    * 
  64.    * The callback object gets the callback with 0 value for start and a 1 value 
  65.    * for end. The callback_info in both cases is the transition being started 
  66.    * or stopped.
  67.    *
  68.    * @param int             xpos  initial x position of the container.
  69.    * @param int             ypos  initial y position of the container.
  70.    * @param interactor      child child object to install under this container.
  71.    * @param callback_object co    object we make callbacks to.
  72.    */
  73.   public anim_mover_container(int xpos, int ypos, interactor child,
  74.               callback_object co) 
  75. {
  76.     super(xpos,ypos,0,false);
  77.     setup_for_fixed_children(1);
  78.     set_child(0,child);
  79.     child.set_x(0);
  80.     child.set_y(0);
  81.     _cback_obj=co;
  82.   }
  83.  
  84.    //had:
  85.    //* @exception general PROPAGATED.
  86.  
  87.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  88.  
  89.   /** Callback number for callback at start of transition. */
  90.   public static final int START_TRANSITION_CALLBACK = 0;
  91.  
  92.   /** Callback number for callback at end of transition. */
  93.   public static final int END_TRANSITION_CALLBACK = 1;
  94.  
  95.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  96.  
  97.   /**
  98.    * Handle start of animation transition.  This transition is used to 
  99.    * position this object over time.  This makes the start of trajectory
  100.    * callback (#0).
  101.    *
  102.    * @param transition trans     the transition object controlling this.
  103.    * @param trajectory traj      the trajectory it is working over.
  104.    * @param double     start_t   start value along trajectory 0..1.
  105.    * @param Object     start_obj first data value out of trajectory (must be 
  106.    *                             a Point object).
  107.    * @param event      e         event "causing" the animation.
  108.    * @param Object     user_info the information associated with then object 
  109.    *                             when the transition was scheduled.
  110.    */
  111.   public void start_transition(transition trans, trajectory traj,
  112.                    double start_t, Object start_obj, event e,
  113.                    Object user_info) {
  114.     Point p=(Point)start_obj;
  115.     if ((active_constraints() & X) == 0) set_x(p.x);
  116.     if ((active_constraints() & Y) == 0) set_y(p.y);
  117.     if (_cback_obj!=null) {
  118.       _cback_obj.callback(this,e,START_TRANSITION_CALLBACK,trans);
  119.     }
  120.   }
  121.  
  122.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  123.  
  124.   /**
  125.    * Handle an animation step.  This animation should be along a trajectory of
  126.    * points, and is used to position this object.
  127.    * 
  128.    * @param transition trans     the transition object controlling this.
  129.    * @param trajectory traj      the trajectory it is working over.
  130.    * @param double     start_t   start value of this step (within 0..1 overall)
  131.    * @param Object     start_obj start data value for this step (this must be 
  132.    *                             a Point object).
  133.    * @param double     end_t     end value of this step (within 0..1 overall)
  134.    * @param Object     end_obj   end data value for this step (this must be 
  135.    *                             a Point object).
  136.    * @param event      e         event "causing" the animation.
  137.    * @param Object     user_info the information associated with then object 
  138.    *                             when the transition was scheduled.
  139.    */
  140.   public void transition_step(transition trans, trajectory traj,
  141.                   double start_t, Object start_obj, 
  142.                   double end_t, Object end_obj,
  143.                   event e, Object user_info) {
  144.     
  145.     Point p=(Point)end_obj;
  146.     if ((active_constraints() & X) == 0) set_x(p.x);
  147.     if ((active_constraints() & Y) == 0) set_y(p.y);
  148.   }
  149.  
  150.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  151.  
  152.   /**
  153.    * Handle the end of animation transition.  This animation should be along 
  154.    * a trajectory of points, and is used to position this object.  This makes
  155.    * the end of trajectory callback (#1).
  156.    * 
  157.    * @param transition trans     the transition object controlling this.
  158.    * @param trajectory traj      the trajectory it is working over.
  159.    * @param double     start_t   start value of this step (within 0..1 overall)
  160.    * @param Object     start_obj start data value for this step (this must be 
  161.    *                             a Point object).
  162.    * @param double     end_t     end value of this step (within 0..1 overall)
  163.    * @param Object     end_obj   end data value for this step (this must be 
  164.    *                             a Point object).
  165.    * @param event      e         event "causing" the animation.
  166.    * @param Object     user_info the information associated with then object 
  167.    *                             when the transition was scheduled.
  168.    */
  169.   public void end_transition(transition trans, trajectory traj,
  170.                  double start_t, Object start_obj,
  171.                  double end_t, Object end_obj,
  172.                  event e, Object user_info) {
  173.     Point p=(Point)end_obj;
  174.     if ((active_constraints() & X) == 0) set_x(p.x);
  175.     if ((active_constraints() & Y) == 0) set_y(p.y);
  176.     if (_cback_obj!=null) {
  177.       _cback_obj.callback(this,e,END_TRANSITION_CALLBACK,trans);
  178.     }
  179.   }
  180.  
  181.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  182.  
  183.   /**
  184.    * This is where we hold our callback object. 
  185.    */
  186.   protected callback_object _cback_obj;
  187.  
  188.   /*
  189.    * Callback object.
  190.    * @return callback_object the object we make callbacks to at the start and 
  191.    *                         end of transitions.
  192.    */
  193.   public callback_object callback_obj() { return _cback_obj;};
  194.  
  195.   /*
  196.    * Set the callback object.
  197.    * @param callback_object co the new callback object.
  198.    */
  199.   public void set_callback_obj(callback_object co) { _cback_obj=co;};
  200.  
  201.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  202. }
  203. /*=========================== COPYRIGHT NOTICE ===========================
  204.  
  205. This file is part of the subArctic user interface toolkit.
  206.  
  207. Copyright (c) 1996 Scott Hudson and Ian Smith
  208. All rights reserved.
  209.  
  210. The subArctic system is freely available for most uses under the terms
  211. and conditions described in 
  212.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  213. and appearing in full in the lib/interactor.java source file.
  214.  
  215. The current release and additional information about this software can be 
  216. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  217.  
  218. ========================================================================*/
  219.